<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %> 
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>发布商品</title>
<link rel="stylesheet" rev="stylesheet" href="<c:url value="/styles/ad/style.css"/>" type="text/css"/>
<script language="JavaScript" type="text/javascript" src="<c:url value="/scripts/jquery-1.4.4.min.js"/>"></script>
<script language="JavaScript" type="text/javascript">
var nameOk = false;
var telOk = true;
function saveDpgl(){
	var dpname = jQuery.trim($("#dpname").val());
	var fzrtel = jQuery.trim($("#dpfzrtel").val());
	var reg =  new RegExp("((\\d{11})|^((\\d{7,8})|(\\d{4}|\d{3})-(\\d{7,8})|(\\d{4}|\\d{3})-(\\d{7,8})-(\\d{4}|\\d{3}|\\d{2}|\\d{1})|(\\d{7,8})-(\\d{4}|\\d{3}|\\d{2}|\\d{1}))$)");
	if(dpname == ""){
		$("#yesOrNo")
		 .css("color","red").text("店铺名称必填");
		if(fzrtel != ""){
			if(!reg.test(fzrtel)){
				$("#telval").css("color","red").text("联系方式格式错误");
				telOk = false;
			}else{
				$("#telval").css("color","green").text("格式正确");
				telOk = true;
			}
		}
		return false;
	}else{
		if(fzrtel != ""){
			if(!reg.test(fzrtel)){
				$("#telval").css("color","red").text("联系方式格式错误");
				telOk = false;
			}else{
				$("#telval").css("color","green").text("格式正确");
				telOk = true;
			}
		}
		if(nameOk && telOk){
			return true;
		}else{
			return false;
		}
	}
}

//验证联系方式
function validTel(){
	var fzrtel = jQuery.trim($("#dpfzrtel").val());
	var reg =  new RegExp("((\\d{11})|^((\\d{7,8})|(\\d{4}|\d{3})-(\\d{7,8})|(\\d{4}|\\d{3})-(\\d{7,8})-(\\d{4}|\\d{3}|\\d{2}|\\d{1})|(\\d{7,8})-(\\d{4}|\\d{3}|\\d{2}|\\d{1}))$)");
	if(fzrtel == ""){
		$("#telval").text("");
		telOk = true;
	}else{
		if(!reg.test(fzrtel)){
			$("#telval").css("color","red").text("联系方式格式错误");
			telOk = false;
		}else{
			$("#telval").css("color","green").text("格式正确");
			telOk = true;
		}
	}
}

//验证店铺名称是否唯一
function validName(){
	var dpname = jQuery.trim($("#dpname").val());
	if(dpname == ""){
		$("#yesOrNo")
			.css("color","red").text("店铺名称必填");
		nameOk = false;
		return;
	}
  	$.ajax({
	   		url : "valDpName",
	   		type : "post",
	   		data:"dpname="+dpname,
	   		dataType:"json",
	   		success : function(data) {
	   			var bool = data.message;
	   			if(bool == "true"){
	   				nameOk = true;
	   				$("#yesOrNo")
	   				.css("color","green").text("店铺唯一，可以注册");
	   			}else{
	   				nameOk = false;
	   				$("#yesOrNo")
	   				.css("color","red").text("店铺已被注册");
	   			}
	   		}
  	 });
}
</script>
<style type="text/css">
<!--
.atten {font-size:12px;font-weight:normal;color:#F00;}
-->
</style>
</head>

<body class="ContentBody">
<form action="<c:url value="/product/doaddpro"/>" method="post"  enctype="multipart/form-data">
  <input type="hidden" value="${dpcode}" name="dpcodeVal"/>
<div class="MainDiv">
<table width="99%" border="0" cellpadding="0" cellspacing="0" class="CContent">
  <tr>
      <th class="tablestyle_title" >商品添加页面</th>
  </tr>
  <tr>
    <td class="CPanel">
		<table border="0" cellpadding="0" cellspacing="0" style="width:100%">
		<tr>
			<td align="left">
				<input type="button" name="Submit2" value="返回" class="button" onclick="window.history.go(-1);"/>			</td>
		</tr>
			<TR>
			<TD width="100%">
				<fieldset style="height:100%;">
				<legend>发布商品</legend>
					<table border="0" cellpadding="2" cellspacing="1" style="width:100%">
					  <tr>
					    <td nowrap align="right" width="15%">商品编号:</td>
					    <td width="20%"><input name='pcode' class="text" style="width:154px" value="${pcode}" disabled="disabled"/>
				        <span class="red">*</span></td>
					    <td width="10%" align="right" nowrap="nowrap">店铺:</td>
					    <td width="55%">
						    <select name="pdpSel" style="width: 200px;">
							    <c:forEach items="${dpglList}" var="dp">
							        <option value="${dp.dpcode}">${dp.dpname}</option>
							    </c:forEach>
							    </select>
					    </td>
					  </tr>
					  <tr>
					    <td width="15%" align="right" nowrap="nowrap">商品名称:</td>
					    <td width="55%" colspan="3"><input class="text" name='pname' style="width:354px" id="pname" value="" />
					    <span class="red">*</span>
					    </td>
					  </tr>
					  <tr>
					    <td nowrap="nowrap" align="right" height="25px">商品状态:</td>
					    <td><input type="radio" checked="checked"  name='pstate' style="width:30px" value="1"/>在售 &nbsp;
					    	<input type="radio" name='pstate' style="width:30px" value="0"/>下架 </td>
					    <td align="right">所属大类:</td>
					    <td>
						    <select name="cpdlSel" style="width: 100px;">
						    <c:forEach items="${cpdlList}" var="cpdl">
						        <option value="${cpdl.dlcode}">${cpdl.dlname}</option>
						    </c:forEach>
						    </select>
						    &nbsp;&nbsp;所属小类：
						    <select name="cpxlSel" style="width: 100px;">
						    <c:forEach items="${cpxlList}" var="cpxl">
						        <option value="${cpxl.xlcode}">${cpxl.xlname}</option>
						    </c:forEach>
						    </select>
					    </td>
					  </tr>
					  
					  <tr>
					    <td align="right">市场价格:</td>
					    <td>
					        <input class="text" name='psj' style="width:150px" value=""/>元<span class="red">*</span>
						</td>
					    <td align="right">俺们价格:</td>
					    <td>
					        <input class="text" name='pxj' id="dpfzrtel" style="width:150px" value=""/>元<span class="red">*</span>
						</td>
					  </tr>
					   <tr>
					    <td align="right">库存数量:</td>
					    <td>
					        <input class="text" name='pkc' style="width:150px" value=""/><span class="red">*</span>
						</td>
					    <td align="right">商品单位:</td>
					    <td>
					        <input class="text" name='pdw' id="dpfzrtel" style="width:150px" value="件"/><span class="red">*</span>
					        <span id="telval"></span>
						</td>
					  </tr>
					   <tr>
					    <td align="right">商品积分:</td>
					    <td>
					        <input class="text" name='pjf' style="width:150px" value=""/>分<span class="red">*</span>
						</td>
					    <td align="right">展示图片:</td>
					    <td>
					        <input type="file" name='ppic' style="width:350px" value=""/><span class="red">* (尺寸：360*400)</span>
						</td>
					  </tr>
					  <tr>
					    <td align="right">商品简介:</td>
					    <td colspan="3"><textarea name="pgljs" cols="100" rows="6">【使用方法】洗衣时，请认明衣物上的洗涤指示。先将适量洗衣粉放入洗衣机的投料盒，充分溶解后投入衣物，选择正确的洗衣程序，开始洗涤。对于特别脏的衣服，洗衣量较大或者水质较硬的地区，按以下方法行进，可达到最佳洗净效果：增加用量，用温水，延长浸泡时间，沾上污渍后请及时处理
					    </textarea></td>
					  </tr>
					  <tr>
					    <td align="right">快速描述:</td>
					    <td colspan="3"><textarea name="pqdesc" cols="100" rows="8"><ul>
<li>【产品名称】:奥妙净蓝全效洗衣粉 3kg</li>
<li>【保质期】:3年</li>
<li>【产地】:China/中国</li>
<li>【商品规格】:3kg</li>
<li>【适用人群】:适用于棉、麻、化纤及混纺等质料之衣物。</li>
</ul>
					    </textarea></td>
					  </tr>
					  <!-- <tr>
					    <td align="right">配送说明:</td>
					    <td colspan="3"><textarea name="pssm" cols="100" rows="8"></textarea></td>
					  </tr>
					  <tr>
					    <td align="right">积分兑换说明:</td>
					    <td colspan="3"><textarea name="jfdhsm" cols="100" rows="8"></textarea></td>
					  </tr> -->
					  </table>
			  <br />
				</fieldset></TD>
		</TR>
		</TABLE>
	 </td>
  </tr>
		<TR>
			<TD colspan="2" align="center" height="50px">
			<input type="submit" name="Submit" value="保存" class="button" />　
			
			<input type="button" name="Submit2" value="返回" class="button" onclick="window.history.go(-1);"/></TD>
		</TR>
		</TABLE>
</div>
</form>
</body>
</html>